<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="vue.js"></script>
    <script type="text/javascript" src="axios.min.js"></script>
</head>
<body>
<h1>The Goods Update Page</h1>
<div id="app">
    <input type="hidden" name="id"  v-model="id">
    <ul>
        <li>name:</li>
        <li><input type="text" name="name"  v-model="name"></li>
        <li>remark:</li>
        <li><textarea rows="3" cols="30" name="remark"  v-model="remark"></textarea></li>
        <li><input type="submit" v-on:click="update" value="Update"></li>
    </ul>
</div>
</body>
<script>
    var config={
        el:'#app',
        data:{
            goods:[],
            id:null,
            name:null,
            remark:null
        },
        mounted:function () {
            var search=location.search;
            search=search.substr(1);
            var array=search.split("=");
            var id=array[1];
            this.findByIdGoods(id);
        },
        methods:{
            update:function(){
                var serverUrl="http://localhost:1314//goods/doUpdateGoods?id="+this.id
                +"&name="+this.name+"&remark="+this.remark;
                axios.get(serverUrl)
                    .then(function (res) {
                        var result=res.data;
                        window.alert(result);
                        this.location.href="goods.html";
                    })
                    .catch()
            },
            findByIdGoods:function (id) {
                debugger;
                var serverUrl="http://localhost:1314//goods/doFindByIdGoods?id="+id;
                axios.get(serverUrl)
                    .then(function (res) {
                        debugger;
                        var result=res.data;
                        this.vue.id=result.id;
                        this.vue.name=result.name;
                        this.vue.remark=result.remark;
                    })
                    .catch()
            }
        }
    }
    var vue=new Vue(config);
</script>
</html>